- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
[Components] xverify - new action components #15321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
 | 
| WalkthroughThis pull request introduces a comprehensive xverify verification module for Pipedream, adding three new verification actions: address, email, and phone verification. The module includes a centralized application configuration in  Changes
 Assessment against linked issues
 Possibly related PRs
 Suggested reviewers
 Poem
 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
 Other keywords and placeholders
 CodeRabbit Configuration File ( | 
d628c0e    to
    d4a4e00      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (3)
components/xverify/xverify.app.mjs (1)
31-33: Consider environment-based URL configuration.The API URL is hardcoded. Consider making it configurable based on environment.
getUrl(path) { - return `https://api.xverify.com/v2${path}`; + const baseUrl = process.env.XVERIFY_API_URL || 'https://api.xverify.com/v2'; + return `${baseUrl}${path}`; },components/xverify/actions/verify-email/verify-email.mjs (1)
6-6: Fix typo in documentation link description.There's a typo in the word "fraudlent" in the description.
- description: "User Agent of the browser that submitted the email address. Can be used to detect fraudlent or risky data. The value must be URL encoded.", + description: "User Agent of the browser that submitted the email address. Can be used to detect fraudulent or risky data. The value must be URL encoded.",components/xverify/actions/verify-address/verify-address.mjs (1)
96-99: Simplify address encoding logic.The conditional encoding of address2 can be simplified using optional chaining.
- address2: address2 - ? encodeURIComponent(address2) - : undefined, + address2: address2?.length ? encodeURIComponent(address2) : undefined,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
- pnpm-lock.yamlis excluded by- !**/pnpm-lock.yaml
📒 Files selected for processing (5)
- components/xverify/actions/verify-address/verify-address.mjs(1 hunks)
- components/xverify/actions/verify-email/verify-email.mjs(1 hunks)
- components/xverify/actions/verify-phone/verify-phone.mjs(1 hunks)
- components/xverify/package.json(2 hunks)
- components/xverify/xverify.app.mjs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (3)
components/xverify/actions/verify-phone/verify-phone.mjs (1)
46-53: 🛠️ Refactor suggestionAdd input validation for phone number format.
The phone parameter is being encoded but there's no validation of the input format. Consider adding validation to ensure the phone number is in a valid format before making the API request.
const response = await verifyPhone({ $, params: { + phone: this.validateAndFormatPhone(phone), - phone: encodeURIComponent(phone), aff, subaff, }, });Add this method to the
methodssection:validateAndFormatPhone(phone) { // Remove any non-digit characters const cleaned = phone.replace(/\D/g, ''); if (cleaned.length < 10) { throw new Error('Phone number must have at least 10 digits'); } return encodeURIComponent(cleaned); }components/xverify/package.json (2)
3-3: LGTM! Version bump follows semantic versioning.The minor version increment (0.0.1 → 0.1.0) appropriately reflects the addition of new features (verification actions) without breaking changes.
15-17: Verify @pipedream/platform version compatibility.Let's ensure we're using a compatible and up-to-date version of the platform package.
✅ Verification successful
@pipedream/platform version 3.0.3 is compatible and up-to-date
The package is using the latest available version from npm registry.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check latest version and changelog of @pipedream/platform # Get the latest version from npm echo "Latest version from npm:" npm view @pipedream/platform version # Check if version 3.0.3 exists echo -e "\nChecking if version 3.0.3 exists:" npm view @pipedream/platform versions | grep "3.0.3" # Look for other components using this package to verify version compatibility echo -e "\nChecking versions used by other components:" fd package.json components -x grep -l "@pipedream/platform" {} \; -x grep "\"version\"" {}Length of output: 65888
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jcortes, LGTM! Ready for QA!
d4a4e00    to
    493cdc9      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
components/xverify/actions/verify-email/verify-email.mjs (1)
23-34: 🛠️ Refactor suggestionAdd validation for IP address and User Agent fields.
The IP and User Agent fields should be validated before being sent to the API.
ip: { type: "string", label: "IP Address", description: "IP address from which a user submitted an email address. Can be used to detect fraudulent or risky submissions.", optional: true, + validate: (ip) => { + const ipRegex = /^(\d{1,3}\.){3}\d{1,3}$/; + if (ip && !ipRegex.test(ip)) { + throw new Error('Invalid IP address format'); + } + }, }, ua: { type: "string", label: "User Agent", description: "User Agent of the browser that submitted the email address. Can be used to detect fraudlent or risky data.", optional: true, + validate: (ua) => { + if (ua && decodeURIComponent(ua) === ua) { + throw new Error('User Agent must be URL encoded'); + } + }, },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
- pnpm-lock.yamlis excluded by- !**/pnpm-lock.yaml
📒 Files selected for processing (5)
- components/xverify/actions/verify-address/verify-address.mjs(1 hunks)
- components/xverify/actions/verify-email/verify-email.mjs(1 hunks)
- components/xverify/actions/verify-phone/verify-phone.mjs(1 hunks)
- components/xverify/package.json(2 hunks)
- components/xverify/xverify.app.mjs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- components/xverify/package.json
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (6)
components/xverify/xverify.app.mjs (1)
50-57: 🛠️ Refactor suggestionEnhance error handling and request configuration in _makeRequest.
The request method should include proper error handling, timeout configuration, and response validation.
_makeRequest({ $ = this, path, params, ...args } = {}) { return axios($, { ...args, url: this.getUrl(path), params: this.getParams(params), + timeout: 30000, // 30 second timeout + validateStatus: (status) => status === 200, + }).catch((error) => { + const status = error.response?.status; + const message = error.response?.data?.message || error.message; + throw new Error(`XVerify API request failed with status ${status}: ${message}`); }); },Likely invalid or redundant comment.
components/xverify/actions/verify-address/verify-address.mjs (2)
7-7: Update component version to match package version.The component version should be consistent with the package version.
- version: "0.0.1", + version: "0.1.0",
85-114: 🛠️ Refactor suggestionAdd input validation and URL encoding for address fields.
The run method should validate required field combinations and encode address parameters.
async run({ $ }) { const { verifyAddress, domain, address1, address2, city, state, zip, urbanization, parse, aff, subaff, } = this; + if (!address1) { + throw new Error('Street Address 1 is required'); + } + + if (!zip && (!city || !state)) { + throw new Error('Either zip code or both city and state must be provided'); + } const response = await verifyAddress({ $, params: { domain, - address1, - address2, - city, - state, + address1: encodeURIComponent(address1), + address2: address2 ? encodeURIComponent(address2) : undefined, + city: city ? encodeURIComponent(city) : undefined, + state: state ? encodeURIComponent(state) : undefined, zip, urbanization, parse, aff, subaff, }, });Likely invalid or redundant comment.
components/xverify/actions/verify-email/verify-email.mjs (1)
7-7: Update component version to match package version.The component version should be consistent with the package version.
- version: "0.0.1", + version: "0.1.0",components/xverify/actions/verify-phone/verify-phone.mjs (2)
7-7: Update component version to match package version.The component version should be consistent with the package version.
- version: "0.0.1", + version: "0.1.0",
44-65: 🛠️ Refactor suggestionAdd phone number validation and error handling.
The run method should validate the phone number format and handle API response errors.
async run({ $ }) { const { verifyPhone, domain, phone, aff, subaff, } = this; + // Basic phone number format validation + const phoneRegex = /^\+?[\d\s-()]+$/; + if (!phoneRegex.test(phone)) { + throw new Error('Invalid phone number format'); + } const response = await verifyPhone({ $, params: { domain, - phone, + phone: encodeURIComponent(phone), aff, subaff, }, }); + if (!response.status) { + throw new Error('Phone verification failed: Invalid response from API'); + }Likely invalid or redundant comment.
493cdc9    to
    5fc72df      
    Compare
  
    | /approve | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
components/xverify/actions/verify-email/verify-email.mjs (2)
1-8: Consider bumping the version number.Since this is a new component with significant functionality, consider starting with version "0.1.0" instead of "0.0.1" to better reflect its initial stable release.
79-80: Enhance error handling in summary message.The summary message should include more details about the verification result.
- $.export("$summary", `Successfully sent email verification with status \`${response.status}\`.`); + const statusMessage = response.error + ? `Failed: ${response.error}` + : `Success: ${response.status}`; + $.export("$summary", `Email verification completed with status \`${statusMessage}\``);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
- pnpm-lock.yamlis excluded by- !**/pnpm-lock.yaml
📒 Files selected for processing (5)
- components/xverify/actions/verify-address/verify-address.mjs(1 hunks)
- components/xverify/actions/verify-email/verify-email.mjs(1 hunks)
- components/xverify/actions/verify-phone/verify-phone.mjs(1 hunks)
- components/xverify/package.json(2 hunks)
- components/xverify/xverify.app.mjs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- components/xverify/package.json
- components/xverify/actions/verify-phone/verify-phone.mjs
- components/xverify/actions/verify-address/verify-address.mjs
🔇 Additional comments (5)
components/xverify/xverify.app.mjs (3)
1-5: LGTM!The import statement and app configuration look good.
41-49: Add input validation in getParams method.The previous review comment about adding input validation in getParams method is still valid.
50-57: Enhance error handling in _makeRequest method.The previous review comment about enhancing error handling in _makeRequest method is still valid.
components/xverify/actions/verify-email/verify-email.mjs (2)
23-34: Add validation for IP address and User Agent.The previous review comment about adding validation for IP address and User Agent is still valid.
56-81: Add email validation and error handling.The previous review comment about adding email validation and error handling is still valid.
| domain: { | ||
| type: "string", | ||
| label: "Domain", | ||
| description: "The domain you have configured in your Xverify settings under which this query should be processed. See below.", | ||
| options() { | ||
| return [ | ||
| this.$auth.domain, | ||
| ]; | ||
| }, | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email Address", | ||
| description: "The email address to be validated (and optionally corrected).", | ||
| }, | ||
| aff: { | ||
| type: "string", | ||
| label: "Affiliate ID", | ||
| description: "The ID you define to identify the affiliate or source of the email for reporting or potential blocking.", | ||
| optional: true, | ||
| }, | ||
| subaff: { | ||
| type: "string", | ||
| label: "Sub-Affiliate ID", | ||
| description: "The sub-identifier you define for the affiliate or source of the email for reporting or potential blocking.", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Phone Number", | ||
| description: "The phone number to be verified.", | ||
| }, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add validation for domain and email properties.
The propDefinitions should include validation for critical fields:
- Domain should be validated for proper format
- Email should be validated for proper format
 domain: {
   type: "string",
   label: "Domain",
   description: "The domain you have configured in your Xverify settings under which this query should be processed. See below.",
+  validate: (domain) => {
+    const domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/;
+    if (!domainRegex.test(domain)) {
+      throw new Error('Invalid domain format');
+    }
+  },
   options() {
     return [
       this.$auth.domain,
     ];
   },
 },
 email: {
   type: "string",
   label: "Email Address",
   description: "The email address to be validated (and optionally corrected).",
+  validate: (email) => {
+    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+    if (!emailRegex.test(email)) {
+      throw new Error('Invalid email format');
+    }
+  },
 },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| domain: { | |
| type: "string", | |
| label: "Domain", | |
| description: "The domain you have configured in your Xverify settings under which this query should be processed. See below.", | |
| options() { | |
| return [ | |
| this.$auth.domain, | |
| ]; | |
| }, | |
| }, | |
| email: { | |
| type: "string", | |
| label: "Email Address", | |
| description: "The email address to be validated (and optionally corrected).", | |
| }, | |
| aff: { | |
| type: "string", | |
| label: "Affiliate ID", | |
| description: "The ID you define to identify the affiliate or source of the email for reporting or potential blocking.", | |
| optional: true, | |
| }, | |
| subaff: { | |
| type: "string", | |
| label: "Sub-Affiliate ID", | |
| description: "The sub-identifier you define for the affiliate or source of the email for reporting or potential blocking.", | |
| optional: true, | |
| }, | |
| phone: { | |
| type: "string", | |
| label: "Phone Number", | |
| description: "The phone number to be verified.", | |
| }, | |
| domain: { | |
| type: "string", | |
| label: "Domain", | |
| description: "The domain you have configured in your Xverify settings under which this query should be processed. See below.", | |
| validate: (domain) => { | |
| const domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/; | |
| if (!domainRegex.test(domain)) { | |
| throw new Error('Invalid domain format'); | |
| } | |
| }, | |
| options() { | |
| return [ | |
| this.$auth.domain, | |
| ]; | |
| }, | |
| }, | |
| email: { | |
| type: "string", | |
| label: "Email Address", | |
| description: "The email address to be validated (and optionally corrected).", | |
| validate: (email) => { | |
| const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | |
| if (!emailRegex.test(email)) { | |
| throw new Error('Invalid email format'); | |
| } | |
| }, | |
| }, | |
| aff: { | |
| type: "string", | |
| label: "Affiliate ID", | |
| description: "The ID you define to identify the affiliate or source of the email for reporting or potential blocking.", | |
| optional: true, | |
| }, | |
| subaff: { | |
| type: "string", | |
| label: "Sub-Affiliate ID", | |
| description: "The sub-identifier you define for the affiliate or source of the email for reporting or potential blocking.", | |
| optional: true, | |
| }, | |
| phone: { | |
| type: "string", | |
| label: "Phone Number", | |
| description: "The phone number to be verified.", | |
| }, | 
| verifyEmail(args = {}) { | ||
| return this.app._makeRequest({ | ||
| path: "/ev", | ||
| ...args, | ||
| }); | ||
| }, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add response type validation in verifyEmail method.
The method should validate the response type from the API to ensure proper error handling.
 verifyEmail(args = {}) {
+  const responseSchema = {
+    status: 'string',
+    data: 'object',
+    error: 'string?'
+  };
   return this.app._makeRequest({
     path: "/ev",
     ...args,
+  }).then(response => {
+    // Validate response against schema
+    Object.entries(responseSchema).forEach(([key, type]) => {
+      const isOptional = type.endsWith('?');
+      const actualType = typeof response[key];
+      const expectedType = isOptional ? type.slice(0, -1) : type;
+      if (!isOptional && !response[key]) {
+        throw new Error(`Missing required field: ${key}`);
+      }
+      if (response[key] && actualType !== expectedType) {
+        throw new Error(`Invalid type for ${key}: expected ${expectedType}, got ${actualType}`);
+      }
+    });
+    return response;
   });
 },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| verifyEmail(args = {}) { | |
| return this.app._makeRequest({ | |
| path: "/ev", | |
| ...args, | |
| }); | |
| }, | |
| verifyEmail(args = {}) { | |
| const responseSchema = { | |
| status: 'string', | |
| data: 'object', | |
| error: 'string?' | |
| }; | |
| return this.app._makeRequest({ | |
| path: "/ev", | |
| ...args, | |
| }).then(response => { | |
| // Validate response against schema | |
| Object.entries(responseSchema).forEach(([key, type]) => { | |
| const isOptional = type.endsWith('?'); | |
| const actualType = typeof response[key]; | |
| const expectedType = isOptional ? type.slice(0, -1) : type; | |
| if (!isOptional && !response[key]) { | |
| throw new Error(`Missing required field: ${key}`); | |
| } | |
| if (response[key] && actualType !== expectedType) { | |
| throw new Error(`Invalid type for ${key}: expected ${expectedType}, got ${actualType}`); | |
| } | |
| }); | |
| return response; | |
| }); | |
| }, | 
WHY
Resolves #15237
Summary by CodeRabbit
Release Notes for XVerify Component
New Features
Improvements
Version Update